<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*  function add(m, n) {
        //类似于数组===有length属性，可以通过【0】来访问成员
        console.log(arguments.length)
        return m + n
      } */

      // add()
      // add(100, 200)
      // add(100, 200, 300)

      function add() {
        console.log(typeof arguments) //object
        let result = 0
        for (let i = 0; i < arguments.length; i++) {
          result += arguments[i]
        }
        return result
      }

      add(1, 2) //3
      add(1, 2, 3) //6
      add(1, 2, 3, 4) //10
    </script>
  </body>
</html>
